package com.venus.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.venus.entity.Track;
import com.venus.service.TrackService;
import com.venus.util.PageUtil;
import com.venus.util.Result;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 学生跟进表 track 前端控制器
 * </p>
 *
 * @author Venus
 * @since 2020-06-08
 */
@RestController



@RequestMapping("/track")
public class TrackController {
    @Resource
    private TrackService trackService;

    /**
     * 条件查询全部的跟踪学生的信息
     * @param track
     * @param pageUtil
     * @return
     */
    @RequestMapping("/selectAllPageTracks")
    public Object selectAllTracks(Track track, PageUtil pageUtil){
        //封装分页对象
        Page<Track> page=new Page<Track>(pageUtil.getPage(),pageUtil.getLimit());
        //封装条件查询
        QueryWrapper<Track> queryWrapper=new QueryWrapper<Track>();
        //isEmpty()等价于  ！=“”  是防止有字符串  但值为空
        if (track.getTrackStuName()!=null && !track.getTrackStuName().isEmpty()){
            queryWrapper.like("trackstuname","track_stu_name");
        }
        //条件和分页数据，调用分页方法查询
        page=trackService.page(page,queryWrapper);
        return new Result(0,"成功",page.getRecords(),page.getTotal());
    }

    /**
     * 查询全部信息
     * @return 全部追踪信息
     */
    @RequestMapping("/selectAll")
    public Object selectAll(){
        return trackService.list();
    }

}
